using System;
using System.Web;
using System.Web.UI;


public partial class Error : Page 

{

    /*void IHttpModule.Init(HttpApplication context)
    {
        context.Error += new EventHandler(app_Error); 
    }*/


    protected void Page_Load(object sender, EventArgs e)
    {
        HttpContext context = this.Context;
        Exception error = context.Server.GetLastError();

        if (error!=null)

            label.Text = error.Message + Environment.NewLine + (error.GetBaseException()!=null?error.GetBaseException().Message:"");

        if(label.Text==string.Empty)
        {
            label.Text = "No error";
        }
    }

    void app_Error(object sender, EventArgs e)
    {

        HttpApplication app = (HttpApplication)sender;

        HttpContext context = app.Context;

        Exception error = context.Server.GetLastError().GetBaseException();


        label.Text = error.Message + Environment.NewLine + error.GetBaseException().Message;
        
        
    }
}
